package com.danbay.cloud.common.api.service;

import com.danbay.cloud.common.api.dto.Base64ImgDto;
import com.danbay.cloud.common.api.dto.CodeValidateDto;
import com.danbay.cloud.common.api.dto.VerifyCodeDto;
import com.danbay.framework.exception.BusinessException;
import com.danbay.framework.springnc.annotation.AutoController;
import com.danbay.framework.springnc.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 验证码服务
 *
 * @author SJG
 *         2018/1/12.
 */
@AutoController
@RequestMapping("/common-service/verifycode")
public interface IVerifyCodeService {

    /**
     * 生成base64验证码图片
     *
     * @param base64Img 生成图片的信息
     * @return base64验证码图片
     */
    @ApiOperation(value = "生成base64验证码图片", notes = "获取到后放到<img/> src中即可，同时保存id，验证时需要把id传递过去验证")
    @RequestMapping(value = "/genBase64Img", method = RequestMethod.GET)
    VerifyCodeDto genBase64Img(Base64ImgDto base64Img) throws BusinessException;

    /**
     * 校验用户输入的验证码是否正确
     *
     * @param codeValidate 待验证的验证码信息
     * @return 是否正确
     */
    @ApiOperation(value = "校验用户输入的验证码是否正确")
    @RequestMapping(value = "/validate", method = RequestMethod.POST)
    boolean validate( @RequestBody CodeValidateDto codeValidate) throws BusinessException;

}
